(provide 'zhang_spellcheck)

;; extra config for misc function
;;=====setup spell-check=======================
;; aspell setting
(setq-default ispell-program-name "aspell")     ;用aspell替换ispell, 更加智能
(setq-default ispell-local-dictionary "american")
(setq-default ispell-complete-word-dict "~/Aspell/dict")
(setq ispell-personal-dictionary "~/Aspell/personal-dictionary") ;设置个人词典
(setq ispell-silently-savep t)          ;保存自己的个人词典不需要询问

;;speck-mode setting
;; (require 'speck)
;; (setq speck-engine (quote Hunspell))
;; (setq speck-hunspell-language-options
;;       (quote (("da" utf-8 nil t nil)
;;               ("de" iso-8859-1 nil t nil)
;;               ("en" utf-8 nil nil nil)
;;               ("fr" iso-8859-1 nil nil nil)
;;               ("it" iso-8859-1 nil nil nil)
;;               ("ru" koi8-r nil nil nil))))
;; (setq speck-hunspell-program "~/hunspell/hunspell.exe")
;; (setq speck-hunspell-library-directory "~/hunspell/")
;; (setq speck-hunspell-default-dictionary-name "en_US")
;;===============flyspell=====================
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
;;(add-hook 'message-mode-hook 'turn-on-flyspell)
(add-hook 'text-mode-hook 'turn-on-flyspell)
;;(add-hook 'c-mode-common-hook 'flyspell-prog-mode)
;;(add-hook 'tcl-mode-hook 'flyspell-prog-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-flyspell)
(add-hook `latex-mode-hook `turn-on-flyspell)
(add-hook `tex-mode-hook `turn-on-flyspell)
(add-hook `bibtex-mode-hook `turn-on-flyspell)
(add-hook `org-mode-hook `turn-off-flyspell)
(put 'LaTex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify)
(setq flyspell-sort-corrections nil)

(defun turn-on-flyspell ()
   "Force flyspell-mode on using a positive arg.  For use in hooks."
   (interactive)
   (flyspell-mode 1)
   ;;(speck-mode 1)
   )
(defun turn-off-flyspell ()
   "turn off flyspell-mode off. For use in org mode."
   (interactive)
   (flyspell-mode -1)
   ;;(speck-mode -1)
   )
